﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using JiveMessenger.Models;
using JiveMessenger.User;
using JiveMessenger.Utilities;
using JiveMessenger.ViewModels;
using JmShared;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Imaging;

namespace JiveMessenger.SampleData
{
    class SampleViewModelMainPage : ViewModelBase, IViewModelMainPage
    {
        public RelayCommand EditFontCommand { get; set; }
        public RelayCommand GetEmoticonsCommand { get; set; }
        public RelayCommand<bool> DisconnectCommand { get; set; }
        public RelayCommand LoginCommand { get; set; }
        public RelayCommand OpenOptionsCommand { get; set; }
        public RelayCommand WindowLoadedCommand { get; set; }
        public RelayCommand<ViewModelTab> CloseTabCommand { get; set; }
        public RelayCommand OpenNotificationsCommand { get; set; }
        public RelayCommand<ViewModelTab> CloseAllTabsCommand { get; set; }
        public RelayCommand<ViewModelTab> PinTabCommand { get; set; }
        public RelayCommand<ViewModelChat> OpenDownloadMessagesCommand { get; set; }
        public RelayCommand OpenEmoticonsCommand { get; set; }
        //public ObservableCollection<IEmoticon> DefaultEmoticons { get; set; }
        public RelayCommand CloseTabsListCommand { get; set; }
        public string JiveIcon
        {
            get
            {
                if (StaticSettings.CurrentTheme == PhoneTheme.Dark || StaticSettings.CurrentTheme == PhoneTheme.HighContrastDark)
                    return "ms-appx:///Assets/Images/jive_icon_white.png";
                else
                    return "ms-appx:///Assets/Images/jive_icon.png";
            }
        }
        public string EmptyClientListText
        {
            get
            {
                if (_currentClient.IsLoggedIn)
                    return "The contact list is empty. You can add contacts from the application bar.";
                else
                    return "Log in to see your contacts.";
            }
        }

        private ObservableCollection<ViewModelTab> _chatViewModels;
        public ObservableCollection<ViewModelTab> ChatViewModels
        {
            get
            {
                if (_chatViewModels == null)
                {
                    var locator = VmHelper.Locator;
                    ObservableCollection<ViewModelTab> items = new ObservableCollection<ViewModelTab>();
                    items.Add(new ViewModelPrivateMessage(locator.CurrentClient, locator.ViewModelContactList.Contacts[0]));
                    foreach (ChatGroup grp in locator.CurrentClient.CurrentUserInfo.ChatGroups.Take(2))
                    {
                        JiveChatGroupModel m = new JiveChatGroupModel(grp.ID, grp.Name, grp.GroupMembers);
                        ViewModelGroupChat vmg = new ViewModelGroupChat(locator.CurrentClient, m);
                        Random rng = new Random();
                        vmg.IsPinned = rng.Next(1, 100) > 50 ? true : false;
                        vmg.DisplayMessage(new DisplayMessage(locator.ViewModelContactList.CurrentUser, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus feugiat non enim eget dapibus. Sed viverra risus vitae tristique pulvinar. ", DisplayMessageOptions.ChatMessageOption, DateTime.Now, true));
                        items.Add(vmg);
                    }
                    _chatViewModels = items;
                }
                return _chatViewModels;
            }
            set
            {
                _chatViewModels = value;
            }
        }

        public ViewModelTab CurrentActiveViewModel
        {
            get
            {
                return ChatViewModels[0];
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public bool IsChatControlVisible
        {
            get
            {
                return true;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool IsLoginControlVisible
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }
        public IClient _currentClient { get; set; }

        public SampleViewModelMainPage(IClient currentClient)
        {
            //DefaultEmoticons = CreateDefaultEmoticonList();
            this._currentClient = currentClient;
        }

        public void RunOnNetworkConnect()
        {

        }

        public void RunOnNetworkDisconnect()
        {

        }

        public void RestoreTabs()
        {
            throw new NotImplementedException();
        }



        public bool IsTabListOpen
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public RelayCommand ShowTabListCommand
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public double VisibleBoundsWidth
        {
            get
            {
                return 400;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public double VisibleBoundsHeight
        {
            get
            {
                return 629;
            }
            set
            {
                throw new NotImplementedException();
            }
        }





        public Uri TabButtonImageUri
        {
            get
            {
                return new Uri("ms-appx:///Assets/AppBar/tabs.png");
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public int EmoticonControlPivotIndex
        {
            get
            {
                return 0;
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public int SelectedPivotItemIndex
        {
            get
            {
                return 0;
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public RelayCommand<ViewModelTab> SelectTabCommand
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public bool ShowFauxKeyboardGrid
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool ShowEmoticonPopup
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public double EmoticonControlHeight
        {
            get
            {
                return 340;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public double EmoticonControlWidth
        {
            get
            {
                return 400;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public double FauxKeyboardHeight
        {
            get
            {
                return 340;
            }
            set
            {
                throw new NotImplementedException();
            }
        }




    }
}
